home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / plugin / walk / birthpad.cpp next >
Encoding:
C/C++ Source or Header  |  2000-04-10  |  1.4 KB  |  74 lines

  1. #include "walk.h"
  2.  
  3. void birth_pad::init()
  4. {
  5.     if (objmesh)
  6.         pos=objmesh->pivotpos;
  7.     animtime0=0;
  8. }
  9.  
  10. int birth_pad::get_custom_param_desc(int i,param_desc *pd)
  11. {
  12.     if (pd!=0)
  13.     switch(i)
  14.     {
  15.         case 0:
  16.             pd->type='3';
  17.             pd->data=&objmesh;
  18.             strcpy(pd->name,"mesh");
  19.             break;
  20.         case 1:
  21.             pd->type='3';
  22.             pd->data=&animobj;
  23.             strcpy(pd->name,"animobj");
  24.             break;
  25.         case 2:
  26.             pd->type='i';
  27.             pd->data=&animtime;
  28.             strcpy(pd->name,"animtime");
  29.             break;
  30.     }
  31.     return 3;
  32. }
  33.  
  34. void birth_pad::draw()
  35. {
  36.     if (objmesh==0) return;
  37.  
  38.     if (node)
  39.         {
  40.         objmesh->color=node->color+dynlight;
  41.         dynlight.null();
  42.         }
  43.  
  44.     glPushMatrix();
  45.     glTranslatef(pos.x,pos.y,pos.z);
  46.     glMultMatrixf((float *)&mat);
  47.     objmesh->draw();
  48.     if (animobj && flyengine->cur_time-animtime0<animtime)
  49.     {
  50.         glDepthMask(GL_FALSE);
  51.         glDisable(GL_CULL_FACE);
  52.         glBlendFunc(GL_ONE,GL_ONE);
  53.         animobj->scrollu=(float)(flyengine->cur_time-animtime0)/animtime;
  54.         animobj->scrollv=(float)(flyengine->cur_time-animtime0)/(-2*animtime);
  55.         animobj->draw();
  56.         glDepthMask(GL_TRUE);
  57.         glEnable(GL_CULL_FACE);
  58.         glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  59.     }
  60.     glPopMatrix();
  61. }
  62.  
  63. int birth_pad::message(vector& p,float rad,int msg,int param,void *data)
  64. {
  65.     if (msg==FLYOBJM_ILLUM)
  66.     {
  67.         float fac=(p-pos).length()/rad;
  68.         if (fac<1.0f)
  69.             dynlight+=*((vector *)data)*(1.0f-fac);
  70.     }
  71.  
  72.     return 1;
  73. }
  74.